package com.woniu.bank.service.impl;

import com.github.pagehelper.PageHelper;
import com.woniu.bank.dto.ClientInfoDTO;
import com.woniu.bank.dto.NewClientfoDTO;
import com.woniu.bank.entity.ClientInfoSheet;
import com.woniu.bank.mapper.ClientInfoSheetMapper;
import com.woniu.bank.service.ClientInfoService;
import com.woniu.bank.vo.ClientInfoSheetRatedVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @description:
 * @author: chench
 * @time: 2023/1/4 15:06
 */
@Service
public class ClientInfoServiceImpl implements ClientInfoService {
    @Autowired
    private ClientInfoSheetMapper clientInfoSheetMapper;

    @Override
    public List<ClientInfoSheet> selectAll(ClientInfoDTO clientInfoDTO) {
        PageHelper.startPage(clientInfoDTO.getCurrentPage(), clientInfoDTO.getPageSize());
        return clientInfoSheetMapper.selectAll(clientInfoDTO);
    }

    @Override
    public int updateStatus(Map<String, Object> map) {
        return clientInfoSheetMapper.updateStatus(map);
    }


    @Override
    public int deleteByPrimaryKey(Long id) {
        return clientInfoSheetMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insertSelective(ClientInfoSheet record) {
        ClientInfoSheet clientInfoSheet = clientInfoSheetMapper.selectByClientDocumentsNumber(record.getClinetDocumentsNumber());
        if (clientInfoSheet==null) {
            return clientInfoSheetMapper.insertSelective(record);
        }
        return -1;
    }

    @Override
    public ClientInfoSheet selectByPrimaryKey(Long id) {
        return clientInfoSheetMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(ClientInfoSheet record) {
            return clientInfoSheetMapper.updateByPrimaryKeySelective(record);

    }

    @Override
    public List<ClientInfoSheetRatedVO> seleteKeHu(NewClientfoDTO newClientfoDTO) {
        return clientInfoSheetMapper.seleteKeHu(newClientfoDTO);
    }


    @Override
    public List<ClientInfoSheetRatedVO> seleteAddKeHu(NewClientfoDTO newClientfoDTO) {
        return clientInfoSheetMapper.seleteAddKeHu(newClientfoDTO);
    }
}



